Skip to content

Conversation

Lumabots
Copy link
Contributor

@Lumabots Lumabots commented Jun 28, 2025

Summary

it add the possibility to use async function for cooldown, it also change the internal function to use ctx instead of only message since slash commands dont have a message
Nothing should be breaking

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Lumabots Lumabots requested a review from a team as a code owner June 28, 2025 14:17
@pullapprove4 pullapprove4 bot requested a review from ChickenDevs June 28, 2025 14:17
@Lumabots Lumabots changed the title fix: update cooldown handling to support async operations feat: update cooldown handling to support async operations Jun 28, 2025
… + correct typehint of max_concurrency since only ctx is passed and never message
@Lumabots
Copy link
Contributor Author

@Soheab brought to my attention that this PR might be breaking — specifically, the renaming of the message parameter to ctx could cause issues if someone is using a message cooldown, like with get_bucket(message=message).
Screenshot 2025-06-29 at 16 39 41

If they’re not using get_bucket(message=...), then there shouldn’t be any problems, since both message and ctx share all the internal attributes being accessed.

That said, I’m personally against keeping the parameter named message, especially since slash commands don’t even have a message attribute.

Let me know how you’d like to handle it. I don’t think this should be an issue — using ctx instead of message shouldn’t break anything unless a user is specifically calling that function, which I doubt many people do.

@Lumabots Lumabots requested a review from a team as a code owner August 30, 2025 13:15
@pullapprove4 pullapprove4 bot requested a review from Dorukyum August 30, 2025 13:16
@Lulalaby Lulalaby force-pushed the master branch 2 times, most recently from b55c125 to 82659b2 Compare August 30, 2025 21:10
@Lulalaby Lulalaby removed the on hold label Aug 30, 2025
Lulalaby
Lulalaby previously approved these changes Aug 31, 2025
@Lulalaby Lulalaby requested review from Paillat-dev and removed request for Dorukyum and ChickenDevs August 31, 2025 16:33
@Lulalaby Lulalaby requested a review from JustaSqu1d August 31, 2025 16:33
@Lulalaby Lulalaby requested a review from a team as a code owner August 31, 2025 16:38
Copy link
Contributor

@DA-344 DA-344 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should've still kept the Message typings as it is still supported, and cooldown can be used in non-context contexts

Comment on lines 306 to 314
from ...ext.commands import Context

if isinstance(ctx, Context):
result = self._factory(ctx.message)
else:
result = self._factory(ctx)
if inspect.isawaitable(result):
return await result
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all can be simplified with:

Suggested change
from ...ext.commands import Context
if isinstance(ctx, Context):
result = self._factory(ctx.message)
else:
result = self._factory(ctx)
if inspect.isawaitable(result):
return await result
return result
return await utils.maybe_coroutine(self._factory, ctx)

Requires importing from discord import utils

Co-authored-by: DA344 <108473820+DA-344@users.noreply.github.com>
Signed-off-by: Lala Sabathil <aiko@aitsys.dev>
@Lumabots
Copy link
Contributor Author

well it was not really ready for review since i thought it was going to be postpone for next, i should have kept it as draft
anyways since it seems it nows have some attention im gonna finish that up

@Lumabots
Copy link
Contributor Author

yeah as i thought, this cannot be merge for V2.7 as it will be breaking for function like is_on_cooldown

@Lulalaby Lulalaby marked this pull request as draft August 31, 2025 20:48
Lumabots and others added 3 commits August 31, 2025 22:49
Co-authored-by: Soheab <33902984+Soheab@users.noreply.github.com>
Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants